<%@ page pageEncoding="UTF-8"%>

<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<%@ taglib uri="/tags/struts-nested" prefix="nested"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="/tags/trymore" prefix="tm"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix='fmt'%>

<script>
	function afterRecover()
	{
		alertMsg.correct("项目恢复成功...")
		navTab.reload();
	}
</script>

<table class="table" width="100%" layoutH="${module eq null ? 170 : ( module eq 'archive' ? (status eq 'follow' || cat eq 'my' ? 170 : 145) : (tid ne null ? 170 : (module eq 'allocate' ? 145 : 136)))}">
	<thead>
		<tr>
			<th align="center">序号</th>
			<c:if test="${module eq 'archive' && cat ne null && cat eq 'my'}">
			<th align="center">参与</th>
			</c:if>
			<th align="center">项目编号</th>
			<th align="center">项目名称</th>
			<th align="center">项目负责人</th>
			<th align="center">项目推荐时间</th>
			<th align="center">行业类别</th>
			<th align="center">合作方名称</th>
			<c:if test="${module eq null || module ne 'archive' || (module eq 'archive' && status eq 'follow')}">
			<th align="center">项目进展</th>
			</c:if>
			<c:if test="${module ne null && module eq 'archive' && status eq 'follow'}">
			<th align="center">项目状态</th>
			</c:if>
			<th align="center">项目登记时间</th>
			<c:if test="${status eq -1}">
			<th align="center" class="thover">退回时间</th>
			<th align="center" class="thover">退回意见</th>
			</c:if>
			<c:if test="${module eq null}">
			<th align="center">项目暂停</th>
			</c:if>
			<th align="center">项目编辑</th>
			<th align="center">项目详细</th>
			<c:if test="${module eq null && (status eq 0 || status eq -1)}">
			<th align="center" class="thover">提交材料</th>
			</c:if>
			<c:if test="${module ne null && module eq 'allocate' && projectStatus ne null}">
			<th align="center" class="thover">项目分配</th>
			</c:if>
			<c:if test="${module ne null && module eq 'allocate' && projectStatus eq null}">
			<th align="center" class="thover">项目已分配</th>
			</c:if>
			<c:if test="${module ne null && module eq 'audit' && phase eq 'trial'}">
			<th align="center" class="thover">初审</th>
			</c:if>
			<c:if test="${module ne null && module eq 'audit' && phase eq 'review'}">
			<th align="center" class="thover">复审</th>
			</c:if>
			<c:if test="${module ne null && module eq 'audit' && tid ne null}">
			<th align="center" class="thover">过会</th>
			</c:if>
			<c:if test="${module ne null && module eq 'archive' && (status eq 'archived' or status eq 'rejected')}">
			<th align="center" class="thover">项目恢复</th>
			</c:if>
		</tr>
	</thead>
	<tbody>
		<logic:present name="datagrid">
			<logic:iterate name="datagrid" property="items" id="entity" indexId="idx">
				<tr ${idx % 2 == 1 ? 'style="background-color: #F5F5F5"' : ''}>
					<td>${idx+1}</td>
					<c:if test="${module eq 'archive' && cat ne null && cat eq 'my'}">
					<td class="icon_${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.id eq entity.projectManager.id ? 'master' : 'attendee'}" style="padding-left: 5px">
						<c:choose>
							<c:when test="${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.id eq entity.projectManager.id}">
								负责
							</c:when>
							<c:when test="${tm:inRange(entity.projectAttendeeIds, sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.id, ',')}">
								参与
							</c:when>
							<c:otherwise>
								---
							</c:otherwise>
						</c:choose>
					</td>
					</c:if>
					<td style="text-align:center">${entity.projectNo}</td>
					<td style="text-align:left">${entity.projectName}</td>
					<td style="text-align:left">
						${entity.projectManager.username}
						<c:if test="${entity.currentProcess eq null && entity.projectStatus eq 1}">(未经部长分配)</c:if>
					</td>
					<td><fmt:formatDate value="${entity.projectRecommendedDate}" type="date" pattern="yyyy-MM-dd"/></td>
					<td style="text-align:left">${entity.projectType.dictKey}</td>
					<td>${entity.projectPartnerName ne '' ? entity.projectPartnerName : '---'}</td>
					<c:if test="${module eq null || module ne 'archive' || (module eq 'archive' && status eq 'follow')}">
					<td>
						<c:choose>
							<c:when test="${entity.currentProcess eq null && entity.projectStatus eq 1}">项目分配</c:when>
							<c:when test="${entity.currentProcess ne null}">${entity.currentProcess.nodeTitle}</c:when>
							<c:otherwise>---</c:otherwise>
						</c:choose>
					</td>
					</c:if>
					<c:if test="${module ne null && module eq 'archive' && status eq 'follow'}">
					<td>
						<c:choose>
							<c:when test="${entity.currentProcess eq null && entity.projectStatus eq 1}">待分配</c:when>
							<c:when test="${entity.projectStatus eq 0}">材料待提交</c:when>
							<c:when test="${entity.projectStatus eq 1}">审批中</c:when>
							<c:when test="${entity.projectStatus eq -1}">审批退回</c:when>
							<c:otherwise>---</c:otherwise>
						</c:choose>
					</td>
					</c:if>
					<td><fmt:formatDate value="${entity.projectPostTime}" type="date" pattern="yyyy-MM-dd"/></td>
					<c:if test="${status eq -1}">
					<td>
						<c:if test="${entity.lastestEvent ne null}">
							<fmt:formatDate value="${entity.lastestEvent.eventTime}" type="date" pattern="yyyy-MM-dd HH:mm"/>
						</c:if>
					</td>
					<td>
						<c:if test="${entity.lastestEvent ne null}">
							${event.lastestEvent.eventComments ne null && event.lastestEvent.eventComments ne '' ? event.lastestEvent.eventComments : '---'}
						</c:if>
					</td>
					</c:if>
					<c:if test="${module eq null}">
					<c:choose>
					<c:when test="${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.id eq entity.projectManager.id || tm:inRange('ROLE_SUPER,ROLE_ADMIN,ROLE_PROJECT_MASTER,ROLE_PROJECT_ASSISTANT', sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.roleKey, ',')}">
					<td>
						<a href="app/project/base.do?action=dialogProjectSuspendPage&pid=${entity.id}" class="oplink" target="dialog" title="`${entity.projectName}`项目暂停" width="405" height="235" rel="prj_suspend_${entity.projectNo}">项目暂停</a>
					</td>
					</c:when>
					<c:otherwise>
					<td>
						<label style="float:none; padding:none" class="opdisabled" title="只有项目经理或项目参与人员可以进行`暂停`操作">项目暂停</label>
					</td>
					</c:otherwise>
					</c:choose>
					</c:if>
					<c:choose>
						<c:when test="${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.id eq entity.projectManager.id || tm:inRange('ROLE_SUPER,ROLE_ADMIN,ROLE_PROJECT_MASTER,ROLE_PROJECT_ASSISTANT', sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.roleKey, ',')}">
							<td>
								<a href="app/project/base.do?action=dialogProjectPage&pid=${entity.id}&op=edit" class="oplink" target="dialog" title="`${entity.projectName}`项目编辑" width="1200" height="600" rel="prj_edit_${entity.projectNo}">项目编辑</a>
							</td>
						</c:when>
						<c:otherwise>
							<td><label style="float:none; padding:none" class="opdisabled" title="只有项目经理或项目参与人员可以进行`编辑`操作">项目编辑</label></td>
						</c:otherwise>
					</c:choose>
					<td>
						<a href="app/project/base.do?action=dialogProjectPage&pid=${entity.id}&op=view" class="oplink" target="dialog" title="`${entity.projectName}`项目详细" width="1200" height="600" rel="prj_detail_${entity.projectNo}">项目详细</a>
					</td>
					<c:if test="${module eq null && (status eq 0 || status eq -1)}">
					<td>
						<a href="app/project/base.do?action=dialogProjectPage&pid=${entity.id}&op=post_stuff&currentindex=1" class="oplink" target="dialog" title="`${entity.projectName}`提交材料" width="1200" height="600" rel="prj_post_${entity.projectNo}">提交材料</a>
					</td>
					</c:if>
					<c:if test="${module ne null && module eq 'allocate'  && projectStatus ne null}">
					<td class="thover">
						<a href="app/project/base.do?action=dialogProjectPage&pid=${entity.id}&op=allocate" class="oplink" target="dialog" title="`${entity.projectName}`项目分配" width="1200" height="600" rel="prj_allocate_${entity.projectNo}">项目分配</a>
					</td>
					</c:if>
					<c:if test="${module ne null && module eq 'allocate' && projectStatus eq null}">
					<td class="thover">
						<a href="app/project/base.do?action=dialogProjectPage&pid=${entity.id}&op=allocate&optype=realoc" class="oplink" target="dialog" title="`${entity.projectName}`项目重新分配" width="1200" height="600" rel="prj_allocate_${entity.projectNo}">重新分配</a>
					</td>
					</c:if>
					<c:if test="${module ne null && module eq 'audit' && phase eq 'trial'}">
					<c:choose>
					<c:when test="${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.id eq entity.projectManager.id}">
					<td class="thover">
						<a href="app/project/base.do?action=dialogProjectPage&pid=${entity.id}&op=audit" class="oplink" target="dialog" title="`${entity.projectName}`初审" width="1200" height="600" rel="prj_allocate_${entity.projectNo}">初审</a>
					</td>
					</c:when>
					<c:otherwise>
					<td class="thover">
						<label style="float:none; padding:none" class="opdisabled" title="只有项目负责人员可以进行`初审`操作">初审</label>
					</td>
					</c:otherwise>
					</c:choose>
					</c:if>
					<c:if test="${module ne null && module eq 'audit' && phase eq 'review'}">
					<td class="thover">
						<a href="app/project/base.do?action=dialogProjectPage&pid=${entity.id}&op=audit" class="oplink" target="dialog" title="`${entity.projectName}`复审" width="1200" height="600" rel="prj_allocate_${entity.projectNo}">复审</a>
					</td>
					</c:if>
					<c:if test="${module ne null && module eq 'audit' && tid ne null}">
					<td class="thover">
						<a href="app/project/base.do?action=dialogProjectPage&pid=${entity.id}&op=audit" class="oplink" target="dialog" title="`${entity.projectName}`复审" width="1200" height="600" rel="prj_allocate_${entity.projectNo}">过会</a>
					</td>
					</c:if>
					<c:if test="${module ne null && module eq 'archive' && (status eq 'archived' or status eq 'rejected')}">
					<td class="thover">
						<a href="app/project/base.do?action=actionRecoverProject&pid=${entity.id}" 
							class="oplink" target="ajaxTodo" callback="afterRecover()" title="确定恢复项目`${entity.projectName}`么?">项目恢复</a>
					</td>
					</c:if>
				</tr>
			</logic:iterate>
		</logic:present>
	</tbody>
</table>

<!-- Pagination -->
<div class="panelBar">
	<div class="pages">
		<span>显示</span>
		<select class="combox" name="numPerPage" onchange="navTabPageBreak({numPerPage:this.value})">
			<option value="20" ${pagingBean ne null && pagingBean.pageSize eq 20 ? 'selected="selected"' : ''}>20</option>
			<option value="50" ${pagingBean ne null && pagingBean.pageSize eq 50 ? 'selected="selected"' : ''}>50</option>
			<option value="100" ${pagingBean ne null && pagingBean.pageSize eq 100 ? 'selected="selected"' : ''}>100</option>
			<option value="200" ${pagingBean ne null && pagingBean.pageSize eq 200 ? 'selected="selected"' : ''}>200</option>
		</select>
		<span>条，共${pagingBean ne null ? pagingBean.totalItems : 0}条</span>
	</div>
	<div class="pagination" targetType="navTab" totalCount="${pagingBean ne null ? pagingBean.totalItems : 0}" numPerPage="${pagingBean ne null ? pagingBean.pageSize : 20}" pageNumShown="${pagingBean ne null ? pagingBean.pageNumShown : 10}" currentPage="${pagingBean ne null ? pagingBean.currentPage : 1}"></div>
</div>